package br.com.consigsys.model.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Table;


/**
 * The persistent class for the tcons_parentesco database table.
 * 
 */
@Entity
@Table(name="tcons_parentesco")
public class TconsParentesco extends BaseEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="ID_PARENTESCO", unique=true, nullable=false)
	private Integer idParentesco;

	@Column(name="DATA_ULT_ALTERACAO")
	private Date dataUltAlteracao;

	@Column(name="DESC_PARENTESCO", length=25)
	private String descParentesco;

	@Column(name="USUARIO_ULT_ALTERACAO", length=150)
	private String usuarioUltAlteracao;

	private Integer versao;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_CONSIGNATARIA")
	private TconsConsignataria consignataria;

    public TconsParentesco() {
    	this.setConsignataria(new TconsConsignataria());
    }

    @PrePersist
    protected void beforePersist(){
    	this.versao = 1;
    	this.dataUltAlteracao = new Date();
    	
    }

    @PreUpdate
    protected void beforeUpdate(){
    	this.dataUltAlteracao = new Date();
    	
    }

    
	public Integer getIdParentesco() {
		return this.idParentesco;
	}

	public void setIdParentesco(Integer idParentesco) {
		this.idParentesco = idParentesco;
	}

	public Date getDataUltAlteracao() {
		return this.dataUltAlteracao;
	}

	public void setDataUltAlteracao(Date dataUltAlteracao) {
		this.dataUltAlteracao = dataUltAlteracao;
	}

	public String getDescParentesco() {
		return this.descParentesco;
	}

	public void setDescParentesco(String descParentesco) {
		this.descParentesco = descParentesco;
	}

	public String getUsuarioUltAlteracao() {
		return this.usuarioUltAlteracao;
	}

	public void setUsuarioUltAlteracao(String usuarioUltAlteracao) {
		this.usuarioUltAlteracao = usuarioUltAlteracao;
	}

	public Integer getVersao() {
		return this.versao;
	}

	public void setVersao(Integer versao) {
		this.versao = versao;
	}

	public TconsConsignataria getConsignataria() {
		return consignataria;
	}

	public void setConsignataria(TconsConsignataria consignataria) {
		this.consignataria = consignataria;
	}

	@Override
	public Integer getId() {
		return this.getIdParentesco();
	}

	@Override
	public void setId(Integer id) {
		this.setIdParentesco(id);
		
	}

}